package com.thkj.business.home.controller;

import com.thkj.business.home.service.HomeService;
import com.thkj.entity.LoginRecord;
import com.thkj.service.*;
import dp.R;
import com.thkj.framework.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 *
 */
@RestController
@RequestMapping("/backstage/home")
public class HomeAction extends BaseController {

    @Autowired
    HomeService homeService;
    @Autowired
    TblConsuUserService tblConsuUserService;

    @Autowired
    TblIndividualService tblIndividualService;

    @Autowired
    TblSecurityAdminService tblSecurityAdminService;

    @Autowired
    ILoginRecordService loginRecordService;

    @RequestMapping("")
    public ModelAndView index() {
        return new ModelAndView("home/index");
    }

    @RequestMapping("/getIndividualTotal")
    public R individualTotal(HttpServletRequest request) {
        //经营户总数量
        Integer individualTotal = tblIndividualService.count();
        return R.success(individualTotal);
    }

    @RequestMapping("/getLoginRecord")
    public R getLoginRecord() {
        //查看一周的登录境况
        List<LoginRecord> records = loginRecordService.queryByRecen();
        return R.success(records);
    }

    @RequestMapping("/getSuperviseUserTotal")
    public R superviseUserTotal(HttpServletRequest request) {
        //监管员总数
        Integer superviseUserTotal = tblSecurityAdminService.queryCountByRoleId("1");
        return R.success(superviseUserTotal);
    }

    @RequestMapping("/getCamersTotal")
    public R camersTotal(HttpServletRequest request) {
        //摄像头总量
        Integer cameraTotal = HikCamerasResoures.getCount("阳东监管局");
        return R.success(cameraTotal);
    }

    @RequestMapping("/getCustomerTotal")
    public R customerTotal(HttpServletRequest request) {
        //消费者数量
        Integer customerTotal = tblConsuUserService.queryCount();
        return R.success(customerTotal);
    }

    @RequestMapping("/getAccessTotal")
    public R accessTotal(HttpServletRequest request) {
        //总访问
        Integer customerTotal = homeService.queryAccessCount();
        return R.success(customerTotal);
    }


}